<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0"><meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />   
        <title>Welcome to Design Zone......</title>
        <link rel="stylesheet" type="text/css" href="../../scripts/ext/resources/css/ext-all.css" />
        <link rel="stylesheet" type="text/css" href="../../scripts/ext/resources/css/file-upload.css" />
        <link rel="stylesheet" type="text/css" href="../../styles/dzbase.css" />
        <script type="text/javascript" src="../../scripts/ext/adapter/ext-base.js">
        </script>
        <script type="text/javascript" src="../../scripts/ext/ext-all.js">
        </script>
        <script type="text/javascript" src="../../scripts/form/FileUploadField.js">
        </script>
        <script type="text/javascript" src="../../scripts/i18nMessage.js">
        </script>
        <script type="text/javascript" src="../../scripts/utils.js">
        </script>
        <script type="text/javascript">
            var acMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=ui.accesscontrol');
            var message = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=message');
            
            var idValue = getPrarmeterValue(window.location, 'id');
            var startPage = getPrarmeterValue(window.location, 'startPage');
            
            Ext.onReady(function(){
                Ext.QuickTips.init();
                Ext.form.Field.prototype.msgTarget = 'side';
                
                var acActionForm = new Ext.FormPanel({
                    labelAlign: 'left',
                    url: '../../servlet/AcActionServlet?action=1',
                    frame: true,
                    title: acMessage.get('ui.accesscontrol.editaction'),
                    bodyStyle: 'padding:5px 5px 5px 5px;margin-top: 2px;',
                    width: '100%',
                    labelWidth: 120,
                    reader: new Ext.data.XmlReader({
                        record: 'item'
                    }, [{
                        name: 'id',
                        mapping: 'id'
                    }, {
                        name: 'actionUrl',
                        mapping: 'actionUrl'
                    }, {
                        name: 'actionNameCn',
                        mapping: 'actionNameCn'
                    }, {
                        name: 'actionNameFr',
                        mapping: 'actionNameFr'
                    }, {
                        name: 'actionNameEn',
                        mapping: 'actionNameEn'
                    }]),
                    items: [{
                        id: 'id',
                        name: 'id',
                        xtype: 'hidden'
                    },{
                        xtype: 'textfield',
                        fieldLabel: acMessage.get('ui.accesscontrol.actionurl'),
                        name: 'actionUrl',
                        anchor: '86%',
                        maxLength: 128,
						allowBlank: false,
                        blankText: message.get('message.edit.noblank'),
						maxLengthText: message.get('message.edit.toolong'),
                        tabIndex: 1
                    },{
                        xtype: 'textfield',
                        fieldLabel: message.get('message.edit.fr'),
                        name: 'actionNameFr',
                        anchor: '86%',
                        maxLength: 512,
						//allowBlank: false,
                        //blankText: message.get('message.edit.noblank'),
						maxLengthText: message.get('message.edit.toolong'),
                        tabIndex: 2
                    },{
                        xtype: 'textfield',
                        fieldLabel: message.get('message.edit.cn'),
                        name: 'actionNameCn',
                        anchor: '86%',
                        maxLength: 512,
						allowBlank: false,
                        blankText: message.get('message.edit.noblank'),
						maxLengthText: message.get('message.edit.toolong'),
                        tabIndex: 3
                    },{
                        xtype: 'textfield',
                        fieldLabel: message.get('message.edit.en'),
                        name: 'actionNameEn',
                        anchor: '86%',
                        maxLength: 512,
						allowBlank: false,
                        blankText: message.get('message.edit.noblank'),
						maxLengthText: message.get('message.edit.toolong'),
                        tabIndex: 4
                    }],
                    
                    buttons: [{
                        text: message.get('message.edit.save'),
                        handler: function(){
                            if (acActionForm.getForm().isValid()) {
                                acActionForm.getForm().submit({
                                    method: 'post',
                                    success: function(form, action){
                                        messageTip.msg(message.get('message.tip'), message.get('message.edit.successful'));
                                        acActionForm.getForm().reset();
                                    },
                                    failure: function(form, action){
                                        messageTip.msg(message.get('message.tip'), message.get('message.edit.unsuccessful'));
                                    }
                                });
                            }
                        }
                    }, {
                        text: message.get('message.edit.reset'),
                        handler: function(){
                            acActionForm.getForm().reset();
                        }
                    }, {
                        text: message.get('message.edit.cancel'),
                        handler: function(){
                            if (startPage != null) {
                                window.location = 'ac_action_list.html?startPage=' + startPage;
                            }
                            else {
                                window.location = 'ac_action_list.html';
                            }
                        }
                    }]
                });
                
                acActionForm.render('acActionForm');
				
				
                if (idValue != null) {
					document.getElementById('id').value = idValue;
					acActionForm.getForm().load({
							url:'../../servlet/AcActionServlet?action=3&id=' + idValue, 
							waitMsg:Ext.LoadMask.prototype.msg, 
							success: function(form, action){
							}
					});
				}
                
            });
        </script>
    </head>
    <body>
        <div id="acActionForm">
        </div>
    </body>
</html>
